<!DOCTYPE html>
<html>
<head>
    <title>php面向对象编程练习</title>
    <meta charset="utf-8">
</head>
<body>
<?php
//定义一个类
/**
* 这是我的第一个类
*/
class shopproduct
{
    public $name ='';
    public $price =100;
    private $cost =0.1;
    protected $amount =;

    //构造方法名称为__construct
    public function __construct($name='',$price =0,$cost =0,$amount =0)
    {
       $this->name = $name;
       $this->price = $price;
       $this->cost = $cost;
       $this->amount = $amount;
    }

    public function display()
    {
        return $this->name . '的价格是:' .;
    }
    public function getcost()
    {
       return $this->cost;
    }
}

//创建我的书籍类
/**
* 书籍类
*/
class Book extends shopproduct
{
    public $author='';
    public $press='';
    public $pubdate='';
    public $version=1;

    function __construct($name='',$price =0,$cost =0,$amount =0,$author='',$press='', $pubdate='',$version=1)
    {
        parent::__construct($name,$price,$cost,$amount)；
        $this->author = $author;
        $this->press = $press;
        $this->pubdate = $pubdate;
        $this->version = $version;
    }
}

//创建一个类的实例
$p1 = new shopproduct('999胃泰'，9.9,0.9,999);

$p2 = new shopproduct();

#book1 = new Book('php面向对象编程练习'，29.9，10,15，'mattow');

echo "<pre>";
var_dump($p1->name,$p1->display,$p1->getcost);
var_dump($book1->name,$book1->display,$book1->getcost);
var_dump($book1->text());
echo "</pre>";

?>
</body>
</html>


